package com.zyg.manager.service.impl;

import com.zyg.common.utils.PageUtils;
import com.zyg.common.utils.Query;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.zyg.manager.dao.TypeTemplateDao;
import com.zyg.manager.entity.TypeTemplateEntity;
import com.zyg.manager.service.TypeTemplateService;


@Service("typeTemplateService")
public class TypeTemplateServiceImpl extends ServiceImpl<TypeTemplateDao, TypeTemplateEntity> implements TypeTemplateService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //1. 定义查询条件包装器
        QueryWrapper<TypeTemplateEntity> queryWrapper = new QueryWrapper<>();
        String key = params.get("key") + "";
        //2. 封装查询条件
        if(StringUtils.isNotBlank(key)){
            queryWrapper.like("name",key);
        }
        //3. 开始进行条件带分页查询
        IPage<TypeTemplateEntity> page = this.page(
                new Query<TypeTemplateEntity>().getPage(params),
                queryWrapper
        );
        //4. 返回分页查询结果
        return new PageUtils(page);
    }

}